

<template>

  <MiniNav :winType="WindowsType.QuickTools"></MiniNav>



  <div class="flex space-x-1" style="user-select: none">
    <div v-for="(item, index) in storeWin.AppList.Tools" :key="index"
         @click="TouchTool(item.id)"  class="mx-0.5 mt-1 w-20 items-center  rounded  border mb-1 hover:cursor-pointer hover:bg-blue-200">

      <!-- tip提示-->
      <q-tooltip  anchor="bottom end" self="top end" :delay="800" max-width="300px">
        快捷键：{{item.hot_key}}
        <!--        <br>输入项：{{item.input_count}}-->
        <!--        <br>完成后操作：{{ item.complete_do}}-->
        <br>模板：{{item.prompt}}
      </q-tooltip>

      <!--角标-->
      <!--      <div class="relative">-->
      <!--                <span-->
      <!--                    class="bg-blue-500 text-white font-bold px-2 py-0.5 rounded-xl absolute -top-0.5 -right-0.5 text-xs">-->

      <!--                  1-->
      <!--                </span>-->
      <!--      </div>-->

      <div class="  ">
        <!-- 文字图标-->
        <div class="mt-1">
                   <span :style="'background:'+ item.tool_icon_color"
                         class=" inline-flex items-center justify-center h-10 w-10 rounded-xl  text-white font-bold uppercase">
                      {{ item.tool_icon }}
                    </span>
        </div>

        <!--标题-->
        <div class="my-1  w-full ">{{ item.tool_name }}</div>
        <!--上下文菜单-->
        <q-menu touch-position context-menu>
          <q-list dense style="min-width: 100px">
            <q-item clickable v-close-popup @click="TouchTool(item.id)">
              <q-item-section><i class="fas fa-play"> 运行</i></q-item-section>
            </q-item>
            <q-item clickable v-close-popup @click="storeIndex.ShowUserToolUpdate(item)">
              <q-item-section><i class="far fa-copy"> 复制</i></q-item-section>
            </q-item>

          </q-list>
        </q-menu>
      </div>
    </div>
  </div>

</template>
<script setup lang="ts">
import {onMounted, ref} from 'vue'
import {WindowMinimise, WindowSetPosition} from "../../wailsjs/runtime/runtime"
import {useWindowsStore, WindowsType} from "../store/windows";
import {GetMousePos} from "../../wailsjs/go/service/SystemService";
import {dto} from "../../wailsjs/go/models";
import {useIndexStore} from "../store";
import MiniNav from "../components/MiniNav.vue";
import {Send} from "../../wailsjs/go/handler/HandlerMessageService";
import {SetLocationByMouse, SetSizeByConfig} from "../utils/SetWinInfo";

onMounted(async () => {
  let size= await  SetSizeByConfig(WindowsType.QuickTools)
  await SetLocationByMouse(size.w,size.h)

  let pos:dto.Pos = await GetMousePos()
  WindowSetPosition(pos.pos_x+30,pos.pos_y)
  storeWin.value.GetToolList()
})



let storeWin=ref(useWindowsStore())
let storeIndex = ref(useIndexStore())
function TouchTool(ToolId :any){
  Send(ToolId,0)
  //最小化
  WindowMinimise()
}
</script>
<style scoped>

</style>